<!DOCTYPE html>
<html>
<head>
	<meta name="renderer" content="webkit" />
	<meta http-equiv="X-UA-COMPATIBLE" content="IE=edge,chrome=1" />
	<title>{$menu_info['title']|default="商家端"} - {$website_info['title']|default="商家端"}</title>
	<meta name="keywords" content="{$home_info['seo_keywords']|default=''}">
	<meta name="description" content="{$home_info['seo_description']|default=''}">
	<link rel="icon" type="image/x-icon" href="__STATIC__/img/shop_bitbug_favicon.ico" />
	<link rel="stylesheet" type="text/css" href="STATIC_CSS/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/ext/layui/css/layui.css" />
	<link rel="stylesheet" type="text/css" href="HOME_CSS/common.css" />
	<script src="__STATIC__/js/jquery-3.1.1.js"></script>
	<script src="__STATIC__/js/jquery.cookie.js"></script>
	<script src="__STATIC__/ext/layui/layui.js"></script>
	<script>
		layui.use(['layer', 'upload', 'element'], function() {});

		window.ns_url = {
			baseUrl: "ROOT_URL/",
			route: ['{:request()->module()}', '{:request()->controller()}', '{:request()->action()}'],
			siteid:0,
			SHOPIMG: 'HOME_IMG'
		};
	</script>
	<script src="__STATIC__/js/common.js"></script>
	<script src="HOME_JS/common.js"></script>
	<style>
		.ns-calendar{background: url("__STATIC__/img/ns_calendar.png") no-repeat center / 16px 16px;}
		.layui-logo{height: 100%;display: flex;align-items: center;}
		.layui-logo a{display: flex;justify-content: center;align-items: center;width: 200px;height: 50px;}
		.layui-logo a img{max-height: 100%;max-width: 100%;}
		.view-container{width: 1200px;margin: 0 auto;}
		.view-main{background: #fff;margin-left: 200px;width: 1000px;font-size: 12px;color: #666;min-height: 500px;margin-top: 50px;border: 1px solid #e5e5e5;padding: 20px;box-sizing: border-box;}
		.ns-account-crumbs{visibility: visible;height: 35px;line-height: 35px;}
		.left_menu ul{min-height: auto !important;}
	</style>
	{block name="resources"}{/block}
</head>
<body>
{block name="body"}
<div class="layui-layout layui-layout-admin">
	{block name='head'}
	<div class="layui-header">
		<div class="layui-logo">
			<a href="{:url('shop/index/index')}">
				{notempty name="$website_info.logo"}
				<img src="{:img($website_info.logo)}">
				{else/}
				<img src="HOME_IMG/shop_logo.png">
				{/notempty}
			</a>
		</div>

		<!-- 账号 -->
		<div class="ns-login-box layui-layout-right">
			<ul class="layui-nav ns-head-account">
				<li class="layui-nav-item layuimini-setting">
					<a href="javascript:;">
						{$sys_user_info['username']}</a>
					<dl class="layui-nav-child">
						<!--<dd class="ns-reset-pass" onclick="resetPassword()">-->
							<!--<a href="javascript:;">修改密码</a>-->
						<!--</dd>-->
						<dd>
							<a href="{:addon_url('home/index/index')}" class="login-out">返回首页</a>
						</dd>
						<dd>
							<a href="{:addon_url('home/login/logout')}" class="login-out">退出登录</a>
						</dd>
					</dl>
				</li>
			</ul>
		</div>
	</div>
	{/block}
	<div class="ns-body-content">
		<!-- 四级导航 -->
		{if condition="isset($forth_menu) && !empty($forth_menu)"}
		<div class="fourstage-nav layui-tab layui-tab-brief" lay-filter="edit_user_tab">
			<ul class="layui-tab-title">
				{volist name="$forth_menu" id="menu"}
				<li class="{$menu.selected == 1 ? 'layui-this' : ''}" lay-id="basic_info"><a href="{$menu.parse_url}">{$menu.title}</a></li>
				{/volist}
			</ul>
		</div>
		{/if}

		<div class="view-body">
			<div class="view-container">

				<!-- 左侧菜单 -->
				{include file="account/left_menu" /}

				<div class="view-main">

					{notempty name='crumbs_view'}

					<span class="layui-breadcrumb ns-account-crumbs">
						{foreach $crumbs_view as $k => $crumbs_v}
								{if $k == ($crumbs_count - 1)}
									<a href="{:addon_url($crumbs_v['url'])}"><cite>{$crumbs_v.title}</cite></a>
								{else/}
									<a href="{:addon_url($crumbs_v['url'])}">{$crumbs_v.title}</a>
								{/if}
						{/foreach}
					</span>
					{/notempty}
					{block name="main"/}
					{/block}
				</div>
			</div>
		</div>
	</div>
	<div class="ns-footer">
		<a class="ns-footer-img" href="#"><img src="{if !empty($copyright.logo)} {:img($copyright.logo)} {else /}__STATIC__/img/copyright_logo.png{/if}" /></a>
		<p>{notempty name="$copyright.company_name"}{$copyright.company_name}{else/}上海牛之云网络科技有限公司{/notempty} {notempty name="$copyright.icp"}<a href={$copyright.copyright_link}>备案号{$copyright.icp}</a>{/notempty}</p>
		{notempty name="$copyright.gov_record"}<a class="gov-box" href={$copyright.gov_url}><img src="HOME_IMG/gov_record.png" alt="">公安备案{$copyright.gov_record}</a>{/notempty}
	</div>
</div>

<!-- 重置密码弹框html -->
<div class="layui-form" id="reset_pass" style="display: none;">
	<div class="layui-form-item">
		<label class="layui-form-label"><span class="required">*</span>原密码：</label>
		<div class="layui-input-block">
			<input type="password" id="old_pass" name="old_pass" required class="layui-input ns-len-mid" maxlength="18" autocomplete="off" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly',true);">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label"><span class="required">*</span>新密码：</label>
		<div class="layui-input-block">
			<input type="password" id="new_pass" name="new_pass" required class="layui-input ns-len-mid" maxlength="18" autocomplete="off" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly',true);">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label"><span class="required">*</span>确认新密码：</label>
		<div class="layui-input-block">
			<input type="password" id="repeat_pass" name="repeat_pass" required class="layui-input ns-len-mid" maxlength="18" autocomplete="off" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly',true);">
		</div>
	</div>

	<div class="ns-form-row">
		<button class="layui-btn ns-bg-color" onclick="repass()">确定</button>
		<button class="layui-btn layui-btn-primary" onclick="closePass()">返回</button>
	</div>
</div>

<script type="text/javascript">
	layui.use('element',function () {
		var element = layui.element;
		element.render('breadcrumb');
	});
	/**
	 * 重置密码
	 */
	var index;
	function resetPassword() {
		index = layer.open({
			type:1,
			content:$('#reset_pass'),
			offset: 'auto',
			area: ['650px']
		});

		setTimeout(function() {
			$(".ns-reset-pass").removeClass('layui-this');
		}, 1000);
	}

	var repeat_flag = false;
	function repass(){
		var old_pass = $("#old_pass").val();
		var new_pass = $("#new_pass").val();
		var repeat_pass = $("#repeat_pass").val();

		if (old_pass == '') {
			$("#old_pass").focus();
			layer.msg("原密码不能为空");
			return;
		}

		if (new_pass == '') {
			$("#new_pass").focus();
			layer.msg("密码不能为空");
			return;
		} else if ($("#new_pass").val().length < 6) {
			$("#new_pass").focus();
			layer.msg("密码不能少于6位数");
			return;
		}
		if (repeat_pass == '') {
			$("#repeat_pass").focus();
			layer.msg("密码不能为空");
			return;
		} else if ($("#repeat_pass").val().length < 6) {
			$("#repeat_pass").focus();
			layer.msg("密码不能少于6位数");
			return;
		}
		if (new_pass != repeat_pass) {
			$("#repeat_pass").focus();
			layer.msg("两次密码输入不一样，请重新输入");
			return;
		}

		if(repeat_flag)return;
		repeat_flag = true;

		$.ajax({
			type: "POST",
			dataType: 'JSON',
			url: ns.url("home/login/modifypassword"),
			data: {"old_pass": old_pass,"new_pass": new_pass},
			success: function(res) {
				layer.msg(res.message);
				repeat_flag = false;

				if (res.code == 0) {
					layer.close(index);
					location.reload();
				}
			}
		});
	}

	function closePass() {
		layer.close(index);
	}

	layui.use('element', function() {
		var element = layui.element;
		element.init();
	});

	function getShopUrl(e) {
		$.ajax({
			type: "POST",
			dataType: 'JSON',
			url: ns.url("home/shop/shopUrl"),
			success: function(res) {
				if(res.data.path.h5.status == 1) {
					layui.use('laytpl', function(){
						var laytpl = layui.laytpl;

						laytpl($("#h5_preview").html()).render(res.data, function (html) {
							var layerIndex = layer.open({
								title: '访问店铺',
								skin: 'layer-tips-class',
								type: 1,
								area: ['600px', '600px'],
								content: html,
							});
						});
					})
				} else {
					layer.msg(res.data.path.h5.message);
				}
			}
		});
	}

</script>

<!-- 店铺预览 -->
<script type="text/html" id="h5_preview">
	<div class="goods-preview">
		<div class="qrcode-wrap">
			<img src="{{ ns.img(d.path.h5.img) }}" alt="推广二维码">
			<p class="tips ns-text-color">扫码访问店铺</p>
		</div>
		<div class="phone-wrap">
			<div class="iframe-wrap">
				<iframe src="{{ d.path.h5.url }}&preview=1" frameborder="0"></iframe>
			</div>
		</div>
	</div>
</script>
{/block}
{block name="script"}
{/block}
</body>
</html>